package com.wanmait.employment.manageController;

import com.github.pagehelper.PageInfo;
import com.wanmait.employment.entity.Address;
import com.wanmait.employment.entity.Company;
import com.wanmait.employment.entity.RecruitmentPost;
import com.wanmait.employment.mapper.RecruitmentPostMapper;
import com.wanmait.employment.service.RecruitmentPostService;
import com.wanmait.employment.util.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/manage/RecruitmentPost")
public class RecruitmentPostController {
    @Resource
    private RecruitmentPostService recruitmentPostService;

    @GetMapping("getProvince")
    public AjaxResult getProvince(Integer parentId){
        List<Address> provinces = recruitmentPostService.getProvince(parentId);
        return AjaxResult.success(provinces);
    }

    @GetMapping("list")
    @ResponseBody
    public AjaxResult list(String title,Integer pageNum,Integer pageSize){
        PageInfo<RecruitmentPost> pageInfo = recruitmentPostService.findAll(title,pageNum,pageSize);
//        System.out.println(pageInfo.getList());
        return AjaxResult.success("",pageInfo);
    }

    @GetMapping("delete")
    public AjaxResult delete(Integer id){
        recruitmentPostService.delete(id);
        return AjaxResult.success("删除成功");
    }
}
